package com.zzy.study.conf;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 学习Properties对象以及相对路径
 * "/" 所有的根目录，比喻D:\
 * "./" 当前根目录，比喻D:\MyEclipseWorkspaces\CFS
 * 
 * @author eason
 *
 */
public class TestProperties {

	public static void main(String[] args) throws IOException {
		
		Properties pro = new Properties();
		InputStream in = new FileInputStream("./conf/log4j.properties");
//		InputStream in = new FileInputStream("conf/log4j.properties");  等价于
		pro.load(in);
		System.out.println(pro.getProperty("log4j.appender.FILE"));
//        pro.store(new FileOutputStream("test.properties"), "test comment");  //产生D:\MyEclipseWorkspaces\CFS\test.properties 
        pro.store(new FileOutputStream("../test.properties"), "test comment");  //产生D:\MyEclipseWorkspaces\test.properties   等价.././test.properties
//        pro.store(new FileOutputStream("/test.properties"), "test comment");  //产生D:\test.properties 
		
	}

}
